<?php 
header("Content-type: text/html; charset=utf-8");
$comments =@mysql_connect('localhost','root','')
      or die('数据库无法连接');
mysql_set_charset('utf8');
@mysql_select_db('neu-video',$comments)
      or die('数据库不存在');
$sql = 'select comments.* from comments join users on comments.uid=users.uid 
join videos on comments.vid=videos.vid';
$result = mysql_query($sql,$comments);
$comments = fetch_array($result);
echo '<table border="1">';
echo '<caption>评论信息表</caption>';
echo '<tr>
<th>评论ID</th>
<th>评论内容</th>
<th>评论日期</th>
<th>评论用户</th>
<th>评论视频</th>
</tr>';
foreach ($comments as $one) {
	echo '<tr>';
	echo '<td>'.$one['cid'].'</td>';
	echo '<td>'.$one['content'].'</td>';
  echo '<td>'.$one['cdate'].'</td>';
  echo '<td>'.$one['uid'].'</td>';
  echo '<td>'.$one['vid'].'</td>';
	echo '</tr>';
}
function fetch_array($Results){
	$arrs = array();
    while ($Results && ($row = mysql_fetch_assoc($Results))!==FALSE) {
	       $arrs[] = $row;
          }
    return $arrs;
	
}
 ?>
